<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ControllerFactory
 *
 * @author juwking
 */
class ControllerFactory {

    private static $activeController;

    public static function build($type) {
        $class = ucfirst($type . 'Page');
        if (!class_exists($class)) {
            throw new Exception('Missing ' . $class . ' class.');
        }
        if (get_class(ControllerFactory::$activeController) == $class)
            throw new Exception('Already done ' . $class . ' class.');

        ControllerFactory::$activeController = new $class;

        return ControllerFactory::$activeController;
    }

}

?>
